import request from '../utils/request'

export const getGroups = () => {
  return request(`/api/task_add_area`)
}
export const getRoles = (dictCode) => {
  return request(`/api/task_add_person/${dictCode}`)
}
export const getTeam = () => {
  return request(`/api/task_type/team`)
}

export const getUser = () => {
  return request(`/api/task_add_user`)
}

export const getWork = (data) => {
  return request('/api/task_add_getTaskByName', {
    method: 'post', 
    data
  })
}

export const postWork = (data) => {
  return request('/api/add_task', {
    method: 'post', 
    data
  })
}

//人员检查地点配置页面接口
export const getNames = () => {
  return request(`/api/queryUserByRoleCode/2008`)
}
export const updateTask = (data) => {
  return request('/api/updateSupervisionScope', {
    method: 'post', 
    data
  })
}
export const getUntreatedSupervisionArea = (params) => {
  return request('/api/queryUntreatedSupervisionArea', {
    params
  })
}
export const getUntreatedCheckType = (params) => {
  return request('/api/queryUntreatedCheckType', {
    params
  })
}
//区域单位配置
export const getSupervisionArea = (params) => {
  return request(`/api/querySupervisionAreaCompanyByArea`,{
    params
  })
}
export const getCheckCompanys = (params) => {
  return request(`/api/queryUntreatedCompanies`,{
    params
  })
}
export const updateAreaCompany = (data) => {
  return request('/api/updateSuperVisionAreaCompany', {
    method: 'put', 
    data
  })
}




export  function transData(a, idStr, pidStr, childrenStr){
  var r = [], hash = {}, id = idStr, pid = pidStr, children = childrenStr, i = 0, j = 0, len = a.length;      		for (; i < len; i++) {			hash[a[i][id]] = a[i];		}		for (; j < len; j++) {			var aVal = a[j], hashVP = hash[aVal[pid]];			if (hashVP) {				!hashVP[children] && (hashVP[children] = []);				hashVP[children].push(aVal);			} else {				r.push(aVal);			}		}		return r; 
}
// export const getMessages = (data) => {
//   return request('/api/addUserMessage', {
//     method: 'post', 
//     data
//   })
// }

//以下为Index接口

export const getWork2 = (data) => {
  return request('/api/queryTaskDetailByCode', {
    method: 'post', 
    data
  })
}
export const getNewWork = (data) => {
  return request('/api/manage_task', {
    method: 'post', 
    data
  })
}

export const postWork2 = (data) => {
  return request('/api/addNewTask', {
    method: 'post', 
    data
  })
}